import React from 'react';
import ReactDOM from 'react-dom';
import { Table, Input, Popconfirm ,DatePicker} from 'antd';

class DatePickerCell extends React.Component {
  
  constructor(props) {
    super(props);
  
    this.state = {
        value: this.props.value,
        editable: this.props.editable || false,
    };
  }
  componentWillReceiveProps(nextProps) {
    // if (nextProps.editable !== this.state.editable) {
    //   this.setState({ editable: nextProps.editable });
    //   if (nextProps.editable) {
    //     this.cacheValue = this.state.value;
    //   }
    // }
    // if (nextProps.status && nextProps.status !== this.props.status) {
    //   if (nextProps.status === 'save') {
    //     this.props.onChange(this.state.value);
    //   } else if (nextProps.status === 'cancel') {
    //     this.setState({ value: this.cacheValue });
    //     this.props.onChange(this.cacheValue);
    //   }
    // }
  }
  shouldComponentUpdate(nextProps, nextState) {

    return nextProps.editable !== this.state.editable ||
           nextState.value !== this.state.value;
  }
  handleChange(e) {
    // const value = e.target.value;
    // this.setState({ value });
    // this.props.self.t(this.props.k,this.props.i,e.target.value);
  }
  render() {
    const { value, editable } = this.state;
    console.log('test00000000000',editable);
    return (
      <div>
        {
          editable ?
            <div>
              <DatePicker
                onChange={e => this.handleChange(e)}
              />
            </div>
            :
            <div className="editable-row-text">
              {value || ' '}
            </div>
        }
      </div>
    );
  }
}
export default DatePickerCell